﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.CommonBot.Routines;
using Styx.WoWInternals.WoWObjects;
using Styx.WoWInternals;
using Styx.TreeSharp;

namespace YourBuddy_MoP
{
    public partial class main : CombatRoutine
    {
        #region AddCount
        public int CAddCount()
        {
            int count = 0;
            foreach (WoWUnit u in ObjectManager.GetObjectsOfType<WoWUnit>(true, true))
            {
                if (Me.CurrentTarget.IsWithinMeleeRange && Me.GotTarget && u.IsAlive && u.Guid != Me.Guid && !u.IsFriendly && u.IsHostile && u.Attackable && !u.IsTotem && !u.IsCritter && !u.IsNonCombatPet && u.GotTarget && !Styx.CommonBot.Blacklist.Contains(u.Guid))
                {
                    count++;
                }
            }
            return count;
        }
        #endregion

        #region AutoAttack
        public bool AutoAttack()
        {
            if (!StyxWoW.Me.IsAutoAttacking && StyxWoW.Me.CurrentTarget.IsWithinMeleeRange)
            {
                StyxWoW.Me.ToggleAttack();
                Logging.Write("Start Autoattack");
                return true;
            }
            return false;
        }
        #endregion

        #region IsTarget
        public bool IsTargetBoss()
        {
            if (!IsTargetDummy() && (StyxWoW.Me.CurrentTarget.CreatureRank == WoWUnitClassificationType.WorldBoss || (StyxWoW.Me.CurrentTarget.Level >= 85 && StyxWoW.Me.CurrentTarget.Elite)))
            {
                return true;
            }
            return false;
        }
        public bool IsTargetDummy()
        {
            if (StyxWoW.Me.CurrentTarget.Name == "Training Dummy" || StyxWoW.Me.CurrentTarget.Name == "Raider's Training Dummy" || StyxWoW.Me.CurrentTarget.Name == "Anatomical Dummy" || StyxWoW.Me.CurrentTarget.Name == "Turnip Punching Bag")
            {
                return true;
            }
            return false;
        }
        public bool IsTargetNPC()
        {
            if (!StyxWoW.Me.CurrentTarget.IsPlayer && (!StyxWoW.Me.CurrentTarget.IsFriendly || StyxWoW.Me.CurrentTarget.IsHostile || StyxWoW.Me.CurrentTarget.Attackable) && !IsTargetBoss() && !IsTargetDummy())
                return true;
            return false;
        }
        public bool IsTargetPlayer()
        {
            if (StyxWoW.Me.CurrentTarget.IsPlayer)
                return true;
            return false;
        }
        #endregion

        #region SpellCast Method
        public static bool CastSpell(string SpellName)
        {
            if (StyxWoW.Me.IsAlive && SpellManager.CanCast(SpellName))
            {
                SpellManager.Cast(SpellName);
                return true;
            }
            return false;
        }
        #endregion
    }
}
